/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comfacauca.xmlc2.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author eorozco
 */
@Entity
@Table(name = "responsable")
@NamedQueries({
    @NamedQuery(name = "Responsable.findAll", query = "SELECT r FROM Responsable r"),
    @NamedQuery(name = "Responsable.findById", query = "SELECT r FROM Responsable r WHERE r.id = :id"),
    @NamedQuery(name = "Responsable.findByCodigo", query = "SELECT r FROM Responsable r WHERE r.codigo = :codigo"),
    @NamedQuery(name = "Responsable.findByLogin", query = "SELECT r FROM Responsable r WHERE r.login = :login"),
    @NamedQuery(name = "Responsable.findByLoginClave", query = "SELECT r FROM Responsable r WHERE r.login = :login and r.clave = :clave"),
    @NamedQuery(name = "Responsable.findByClave", query = "SELECT r FROM Responsable r WHERE r.clave = :clave")})
public class Responsable implements Serializable {
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Correo electrónico no válido")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 100)
    @Column(name = "email")
    private String email;
    @Column(name = "usrglpi")
    private Integer usrglpi;
    @OneToMany(mappedBy = "idAutor")
    private Collection<Acciones> accionesCollection;
//    @JoinColumn(name = "id_etapa", referencedColumnName = "id")
//    @ManyToOne
//    private Etapa idEtapa;
    @OneToMany(mappedBy = "idAutor")
    private Collection<Avance> avanceCollection;
    @OneToMany(mappedBy = "idAutor")
    private Collection<Comentario> comentarioCollection;
    @Size(max = 100)
    @Column(name = "nombre")
    private String nombre;
    @OneToMany(mappedBy = "idResponsable")    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 16)
    @Column(name = "codigo")
    private String codigo;
    @Size(max = 45)
    @Column(name = "login")
    private String login;
    @Size(max = 45)
    @Column(name = "clave")
    private String clave;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idResponsable")
    private Collection<Requerimiento> requerimientoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idResponsable")
    private Collection<Iteracion> iteracionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idResponsable")
    private Collection<Proyecto> proyectoCollection;

   
            
    public Responsable() {
    }

    public Responsable(Integer id) {
        this.id = id;
    }

    public Responsable(Integer id, String codigo) {
        this.id = id;
        this.codigo = codigo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getClave() {
        return clave;
    }

    public void setClave(String clave) {
        this.clave = clave;
    }

    public Collection<Requerimiento> getRequerimientoCollection() {
        return requerimientoCollection;
    }

    public void setRequerimientoCollection(Collection<Requerimiento> requerimientoCollection) {
        this.requerimientoCollection = requerimientoCollection;
    }

    public Collection<Iteracion> getIteracionCollection() {
        return iteracionCollection;
    }

    public void setIteracionCollection(Collection<Iteracion> iteracionCollection) {
        this.iteracionCollection = iteracionCollection;
    }

    public Collection<Proyecto> getProyectoCollection() {
        return proyectoCollection;
    }

    public void setProyectoCollection(Collection<Proyecto> proyectoCollection) {
        this.proyectoCollection = proyectoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Responsable)) {
            return false;
        }
        Responsable other = (Responsable) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.comfacauca.xmlc2.entidades.Responsable[ id=" + id + " ]";
    }
  
    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Collection<Comentario> getComentarioCollection() {
        return comentarioCollection;
    }

    public void setComentarioCollection(Collection<Comentario> comentarioCollection) {
        this.comentarioCollection = comentarioCollection;
    }

//    public Etapa getIdEtapa() {
//        return idEtapa;
//    }
//
//    public void setIdEtapa(Etapa idEtapa) {
//        this.idEtapa = idEtapa;
//    }

    public Collection<Avance> getAvanceCollection() {
        return avanceCollection;
    }

    public void setAvanceCollection(Collection<Avance> avanceCollection) {
        this.avanceCollection = avanceCollection;
    }

    public Collection<Acciones> getAccionesCollection() {
        return accionesCollection;
    }

    public void setAccionesCollection(Collection<Acciones> accionesCollection) {
        this.accionesCollection = accionesCollection;
    }

    public Integer getUsrglpi() {
        return usrglpi;
    }

    public void setUsrglpi(Integer usrglpi) {
        this.usrglpi = usrglpi;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

   
    
    
}
